/**
 * 
 */
package com.palnar.ilecker.manager;

import android.content.Context;
import android.content.SharedPreferences;


/**
 * @author Kishore
 *
 */
public class AppPreferenceManager {
	
	
	private static String PREFERENCE_VALUE="ILECKER";

	public static void saveIp(String ip,Context context) 
	{
		SharedPreferences preferences;
		preferences = context.getSharedPreferences(PREFERENCE_VALUE,Context.MODE_PRIVATE);
		preferences.edit().putString("ip", ip).commit();
	}
	
	public static String getIp(Context context) 
	{
		SharedPreferences preferences;
		preferences = context.getSharedPreferences(PREFERENCE_VALUE,Context.MODE_PRIVATE);
		String  ip = preferences.getString("ip", "");
		return ip;
	}
	
	
	public static void savePort(String port,Context context) 
	{
		SharedPreferences preferences;
		preferences = context.getSharedPreferences(PREFERENCE_VALUE,Context.MODE_PRIVATE);
		preferences.edit().putString("port", port).commit();
	}
	
	public static String getPort(Context context) 
	{
		SharedPreferences preferences;
		preferences = context.getSharedPreferences(PREFERENCE_VALUE,Context.MODE_PRIVATE);
		String  port = preferences.getString("port", "");
		return port;
	}
	
	
	/*public static boolean saveHomeIcons(Integer [] array, Context mContext) {
		SharedPreferences prefs = mContext.getSharedPreferences(
				PREFERENCE_VALUE, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = prefs.edit();
		for (int i = 0; i < array.length; i++)
			editor.putInt("homeicons" + "_" + i, array[i]);
		return editor.commit();
	}
public static Integer [] getHomeIcons(Context mContext) {
		Integer [] value = { R.drawable.visual_voicebox_icon, R.drawable.groups_icon, R.drawable.account_icon,  R.drawable.greetings_icon};
		SharedPreferences prefs = mContext.getSharedPreferences(
				PREFERENCE_VALUE, Context.MODE_PRIVATE);
		for (int i = 0; i < value.length; i++)
			value[i] = prefs.getInt("homeicons" + "_" + i, value[i]);
		return value;
	}
	public static void saveIcons(Context ctx,ArrayList<View> icons)
	{
			SharedPreferences prefs = ctx.getSharedPreferences(PREFERENCE_VALUE, Context.MODE_PRIVATE);
	        Editor editor = prefs.edit();
	        editor.putString("history", ObjectSerializer.serialize(icons));
	        editor.commit();
	}*/
	/*@SuppressWarnings("unchecked")
	public static ArrayList<View> getIcons(Context ctx)
	{
		ArrayList<View> listItems = null;
		Integer [] value = { R.drawable.visual_voicebox_icon, R.drawable.groups_icon, R.drawable.account_icon,  R.drawable.greetings_icon};
		listItems 	 	= new ArrayList<View>();
		for (int i = 0; i < value.length; i++)
		{
			View view = new View(ctx);
			view.setBackgroundResource(value[i]);
			listItems.add(view);
		}
		Utils.printLog("list size"+listItems.size());
		saveIcons(ctx, listItems);
		 SharedPreferences prefs = ctx.getSharedPreferences(PREFERENCE_VALUE, Context.MODE_PRIVATE);
	     try {
	    	 listItems = (ArrayList<View>) ObjectSerializer.deserialize
	    			 (prefs.getString("history", ObjectSerializer.serialize(new ArrayList<View>())));
	    	 Utils.printLog("new list size"+listItems.size());
	     } 
	     catch (IOException e)
	     {
	         e.printStackTrace();
	     }
		return listItems;
	}*/
}
